import React, { useState, useEffect, useMemo, memo } from 'react';
import styles from './index.less';
import useModel from '../../useModel.js';
import Connect from '@/components/Connect';
import IconFont from '@/components/IconFont';
import Toolbar from '@/components/Toolbar';
import { message } from 'antd';

const ToolbarWrap = () => {
  const { dictionaryImportProps } = useModel(model => [model.dictionaryImportProps]);
  let toolbar = [
    {
      type: 'upload',
      buttonName: '导入字典表',
      name: 'file',
      theme: 'white',
      accept: '.xlsx, .xls',
      showUploadList: false,
      className: styles['import-wrap'],
      icon: <IconFont type={'icondaoru'} />,
      beforeUpload: file => {
        let formData = new FormData();
        formData.append('fsuTypeId', JSON.parse(localStorage.getItem('deviceType')).id);
        formData.append('file', file);
        dictionaryImportProps.run(formData);

        return false;
      },
    },
    {
      type: 'button',
      name: '下载导入模型',
      theme: 'white',
      icon: <IconFont type={'iconxiazai'} />,
      onClick: () => {
        window.location.href = '/api/dictionary/template';
      },
    },
  ];

  return <Toolbar modules={toolbar} leftSpan={16} fields={{}} className={styles['toolbar-wrap']} />;
};
export default ToolbarWrap;
